package Thread;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.message.BasicNameValuePair;
import org.apache.log4j.Logger;

import Utils.Http;

public class AnJieRequestThread implements Runnable {
	static Logger logger = Logger.getLogger(AnJieRequestThread.class);

	@Override
	public void run() {
		try {
			// StringUtils.isNotBlank(getCode)
			List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
			if (sign != null) {
				nameValuePairs.add(new BasicNameValuePair("sign", sign));
			}
			if (deviceSeq != null) {
				nameValuePairs.add(new BasicNameValuePair("deviceSeq",
						deviceSeq));
			}
			if (parcelId != null) {
				nameValuePairs
						.add(new BasicNameValuePair("parcelId", parcelId));
			}
			if (saveTime != null) {
				nameValuePairs
						.add(new BasicNameValuePair("saveTime", saveTime));
			}
			if (parcelNum != null) {
				nameValuePairs.add(new BasicNameValuePair("parcelNum",
						parcelNum));
			}
			if (userMobileNum != null) {
				nameValuePairs.add(new BasicNameValuePair("userMobileNum",
						userMobileNum));
			}
			if (boxNum != 0) {
				nameValuePairs.add(new BasicNameValuePair("boxNum", String
						.valueOf(boxNum)));
			}
			if (expressBranchId != null) {
				nameValuePairs.add(new BasicNameValuePair("expressBranchId",
						expressBranchId));
			}
			if (courierId != null) {
				nameValuePairs.add(new BasicNameValuePair("courierId",
						courierId));
			}
			if (mobileNum != null) {
				nameValuePairs.add(new BasicNameValuePair("mobileNum",
						mobileNum));
			}
			if (parcelStatus != -1) {
				nameValuePairs.add(new BasicNameValuePair("parcelStatus",
						String.valueOf(parcelStatus)));
			}
			if (getTime != null) {
				nameValuePairs.add(new BasicNameValuePair("getTime", getTime));
			}
			String responseString = null;
//			logger.info(nameValuePairs);
			responseString = Http.postByPair(url, nameValuePairs);
//			logger.info("responseString------------------------------>"+responseString);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	// http://118.244.139.81:8080/erp/feedback
	private String url = null;
	private String sign = null;
	private String deviceSeq = null;
	private String parcelId = null;
	private String saveTime = null;
	private String parcelNum = null;
	private String userMobileNum = null;
	private int boxNum = 0;
	private String expressBranchId = null;
	private String courierId = null;
	private String mobileNum = null;
	private int parcelStatus = -1;
	private String getTime = null;

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	public String getDeviceSeq() {
		return deviceSeq;
	}

	public void setDeviceSeq(String deviceSeq) {
		this.deviceSeq = deviceSeq;
	}

	public String getParcelId() {
		return parcelId;
	}

	public void setParcelId(String parcelId) {
		this.parcelId = parcelId;
	}

	public String getSaveTime() {
		return saveTime;
	}

	public void setSaveTime(String saveTime) {
		this.saveTime = saveTime;
	}

	public String getParcelNum() {
		return parcelNum;
	}

	public void setParcelNum(String parcelNum) {
		this.parcelNum = parcelNum;
	}

	public String getUserMobileNum() {
		return userMobileNum;
	}

	public void setUserMobileNum(String userMobileNum) {
		this.userMobileNum = userMobileNum;
	}

	public int getBoxNum() {
		return boxNum;
	}

	public void setBoxNum(int boxNum) {
		this.boxNum = boxNum;
	}

	public String getExpressBranchId() {
		return expressBranchId;
	}

	public void setExpressBranchId(String expressBranchId) {
		this.expressBranchId = expressBranchId;
	}

	public String getCourierId() {
		return courierId;
	}

	public void setCourierId(String courierId) {
		this.courierId = courierId;
	}

	public String getMobileNum() {
		return mobileNum;
	}

	public void setMobileNum(String mobileNum) {
		this.mobileNum = mobileNum;
	}

	public int getParcelStatus() {
		return parcelStatus;
	}

	public void setParcelStatus(int parcelStatus) {
		this.parcelStatus = parcelStatus;
	}

	public String getGetTime() {
		return getTime;
	}

	public void setGetTime(String getTime) {
		this.getTime = getTime;
	}

}
